<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/2/26
 * Time: 14:27
 */

namespace App\Http\Controllers\MiniProgram;


use App\DynamicComment;
use App\Http\Logics\MiniProgram\DynamicCommentLogic;
use App\Http\Traits\DynamicCommentTrait;
use App\Http\Controllers\BaseController;
class DynamicCommentController extends BaseController
{
    use DynamicCommentTrait;

    /**
     * @SWG\Post(
     *     path="/dynamicComment/create",
     *     tags={"DynamicComment"},
     *     description="评论动态",
     *     operationId="createDynamicComment",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="re_user_id",
     *         in="query",
     *         description="回复的用户ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="dynamic_id",
     *         in="query",
     *         description="动态ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="parent_id",
     *         in="query",
     *         description="父评论ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="content",
     *         in="query",
     *         description="评论内容",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createDynamicComment()
    {
        $dynamic_id = $this->dynamic_id;
        $parent_id = $this->parent_id;
        $loginSession = $this->loginSession;
        $content = $this->content;
        $re_user_id = $this->re_user_id;
        $data = [
            'dynamic_id' => $dynamic_id,
            'parent_id' => $parent_id,
            'loginSession' => $loginSession,
            'content' => $content,
            're_user_id' => $re_user_id
        ];
        $response = DynamicCommentLogic::createDynamicComment($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/dynamicComment/list",
     *     tags={"DynamicComment"},
     *     description="评论列表",
     *     operationId="getDynamicCommentList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="dynamic_id",
     *         in="query",
     *         description="动态ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="parent_id",
     *         in="query",
     *         description="父评论ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getDynamicCommentList()
    {
        $dynamic_id = $this->dynamic_id;
        $dynamic_comment_id = $this->dynamic_comment_id;
        $limit = $this->limit;
        $parent_id = $this->parent_id;
        $data = [
            'dynamic_id' => $dynamic_id,
            'dynamic_comment_id' => $dynamic_comment_id,
            'status' => DynamicComment::ONLINE,
            'limit' => $limit,
            'parent_id' => $parent_id
        ];
        $response = DynamicCommentLogic::getDynamicCommentList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}